var UId = getParameter("UId");
var date = new Date();
var target;
// var sessionData = getParameter("sessionData");
$(function() {
	/*
	 * var urlStr = serverPath + "/server/entryQuestionnaire.do"; var jsonStr =
	 * '{method:"getUidBySession",sessionData:' + sessionData + '}';
	 * UseAjax(urlStr, jsonStr, document.cookie, rt, '1');
	 */
	charts();
});

function charts() {
	target = 4000;
	var today = getWeek(date);
	var week = [ "周一", "周二", "周三", "周四", "周五", "周六", "周日" ];
	var i = week.indexOf(today);
	var weeks = new Array();
	for (var int = 0; int < week.length; int++) {
		if (i <= 6) {
			weeks.push(week[i]);
			i++;
		} else {
			i = 0;
			weeks.push(week[i]);
			i++;
		}
	}
	// alert(formattime(date));
	// var dates =[formattime(getLastDay(date, 3)),formattime(getLastDay(date,
	// 2)), formattime(getLastDay(date, 1)), formattime(date),
	// formattime(getNextDay(date, 1)), formattime(getNextDay(date, 2)),
	// formattime(getNextDay(date, 3))];
	$('#container')
			.highcharts(
					{
						chart : {
							type : 'column'
						},
						title : {
							text : ''
						},
						subtitle : {
							text : null
						},
						xAxis : {
							categories : weeks
						},
						yAxis : {
							min : 0,
							max : 10000,
							// categories : steps,
							title : {
								enabled : false,
							},
							labels : {
								formatter : function() {
									return "" + this.value + "步";
								}
							}
						},
						tooltip : {
							headerFormat : '<span style="font-size:10px">{point.key}</span><table>',
							pointFormat : '<tr><td style="color:{series.color};padding:0"> </td>'
									+ '<td style="padding:0"><b>{point.y:.1f} 步</b></td></tr>',
							footerFormat : '</table>',
							shared : true,
							useHTML : true
						},
						plotOptions : {
							column : {
								pointPadding : 0.2,
								borderWidth : 0
							}
						},
						credits : {
							enabled : false
						},
						legend : {
							enabled : false
						},
						series : [ {
							name : null,
							data : [ {
								'color' : getColor(1200),
								'y' : 1200
							}, {
								'color' : getColor(5000),
								'y' : 5000
							}, null, null, null, null, null ]

						} ]
					});
}
function getColor(value) {
	var color;
	alert(value);
	alert(target);
	alert(value < target);
	if (value < target) {
		color = "#E79C75";
	} else {
		color = "#CBE776";
	}
	return color;
}
function getWeek(date) {
	var week;
	switch (date.getDay()) {
	case 1:
		week = "周一";
		break;
	case 2:
		week = "周二";
		break;
	case 3:
		week = "周三";
		break;
	case 4:
		week = "周四";
		break;
	case 5:
		week = "周五";
		break;
	case 6:
		week = "周六";
		break;
	default:
		week = "周日";
	}
	return week;
}
// 获取url参数
function getParameter(param) {
	var query = window.location.search;
	var iLen = param.length;
	var iStart = query.indexOf(param);
	if (iStart == -1)
		return "";
	iStart += iLen + 1;
	var iEnd = query.indexOf("&", iStart);
	if (iEnd == -1)
		return query.substring(iStart);
	return query.substring(iStart, iEnd);
}